﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media;
using Microsoft.Phone.Maps.Toolkit;
using Microsoft.Phone.Maps.Controls;
using System.Device.Location;
using SpaceNeedle.x6473.WindowsPhone.ViewModels;
using SpaceNeedle.x6473.WindowsPhone.Common;
using Windows.Networking.Connectivity;
using SpaceNeedle.SDK.WindowsPhone.Views;


namespace SpaceNeedle.x6473.WindowsPhone.Views
{
    public class AlertsView : ViewBase<AlertsViewModel> { }

    public partial class Alerts : AlertsView
    {
        public Alerts()
        {
            InitializeComponent();
            this.Loaded += Alerts_Loaded;
        }

        void Alerts_Loaded(object sender, RoutedEventArgs e)
        {
            
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string alertId = string.Empty;

            NavigationContext.QueryString.TryGetValue("alertId", out alertId);

            if (!string.IsNullOrEmpty(alertId))
            {
                AppViewModel.Instance.Properties.SelectedAlertId = alertId;
            }

            base.OnNavigatedTo(e);
        }

        private void OnClearAlertsAppBarButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Tem certeza que deseja limpar a lista de Alertas?", "Alertas", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                this.ViewModel.ClearAlertsCommand.Execute(null);
            }
        }

        private void OnUploadsMenuItem_Click(object sender, EventArgs e)
        {
            this.ViewModel.UploadsCommand.Execute(null);              
        }

        private void OnAboutMenuItem_Click(object sender, EventArgs e)
        {
            this.ViewModel.AboutCommand.Execute(null);
        }

        private void OnSignOutMenuItem_Click(object sender, EventArgs e)
        {
            this.ViewModel.SignOutCommand.Execute(null);
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox list = sender as ListBox;
            list.SelectedIndex = -1;
        }
    }
}